<template>
  <div id="app">
    <router-view/>
<!--    <MenuList :user="user" />
    <Table />
    <Search :user="user" :editUser="editUser" @addUser="addUser"/>-->
  </div>
</template>

<script>
import MenuList from "./components/MenuList.vue";
import Table from "./components/Table.vue";
import Search from "./components/Search.vue";
import PubSub from "pubsub-js"

export default {
  name: 'App',
  components: {
    MenuList,
    Table,
    Search
  },
  data() {
    return {
      user: {
        id: 1,
        name: 'lisi'
      }
    };
  },
  methods: {
    editUser() {
      this.user.id = 2;
      this.user.name = 'zhangsan';
    },
    addUser(user){
      console.log("自定义emit函数导入测试")
    }
  },
  mounted(){
    PubSub.subscribe('msg',(name,data)=>{//接收订阅消息，对于已发布的消息进行订阅
      console.log("--------------");
      console.log(data);
      console.log("--------------");
    })
  }
};
</script>

<style scoped>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
